<?php

class User_model extends CI_Model {

    function __construct() {
        // Call the Model constructor
        parent::__construct();
    }

    function get_uid_by_user_pass($usr, $pass) {
        $query=$this->db->query("SELECT password,id FROM `users` WHERE `username`=".$this->db->escape($usr)." LIMIT 1");
        if($query->num_rows() > 0)
        {
            $row = $query->row();
            if (sha1($pass) == $row->password)
                return $row->id;
        }
        return 0;
    }
    

}